package com.uyun.app.main.dao.impl;

import com.uyun.app.main.dao.MainDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.Map;

@Repository(value="mainDao")
public class MainDaoImpl implements MainDao {
        
	@Autowired
	private JdbcTemplate jdbcTemplate;
	
	@Override
	public Map<String,Object> validateUser(String username,String password){
		
		Map<String,Object> map ;
		
		try{
		map =jdbcTemplate.queryForMap("select username from lottery_rbac.user where username =? and password=? limit 1 ", username,password);
		}catch(Exception e){
            return null;
        }



		return map;
		
		
	}

	@Override
	public String getPwdByUserName(String username) {
		
		String password;
		
		try{
            password =jdbcTemplate.queryForObject("select password from user where username =? limit 1 ",String.class,username);
		}catch(Exception e){
			return "";
		}

		return password;
	}
	
	
}
